home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 15
/
Aminet 15 - Nov 1996.iso
/
Aminet
/
dev
/
gcc
/
ixemsdk.lha
/
man
/
cat2
/
accept.0
< prev
next >
Wrap
Text File
|
1996-09-01
|
4KB
|
80 lines
ACCEPT(2) UNIX Programmer's Manual ACCEPT(2)
NNAAMMEE
aacccceepptt - accept a connection on a socket
SSYYNNOOPPSSIISS
##iinncclluuddee <<ssyyss//ttyyppeess..hh>>
##iinncclluuddee <<ssyyss//ssoocckkeett..hh>>
_i_n_t
aacccceepptt(_i_n_t _s, _s_t_r_u_c_t _s_o_c_k_a_d_d_r _*_a_d_d_r, _i_n_t _*_a_d_d_r_l_e_n)
DDEESSCCRRIIPPTTIIOONN
The argument _s is a socket that has been created with socket(2), bound
to an address with bind(2), and is listening for connections after a
listen(2). The aacccceepptt() argument extracts the first connection request
on the queue of pending connections, creates a new socket with the same
properties of _s and allocates a new file descriptor for the socket. If
no pending connections are present on the queue, and the socket is not
marked as non-blocking, aacccceepptt() blocks the caller until a connection is
present. If the socket is marked non-blocking and no pending connections
are present on the queue, aacccceepptt() returns an error as described below.
The accepted socket may not be used to accept more connections. The
original socket _s remains open.
The argument _a_d_d_r is a result parameter that is filled in with the ad-
dress of the connecting entity, as known to the communications layer.
The exact format of the _a_d_d_r parameter is determined by the domain in
which the communication is occurring. The _a_d_d_r_l_e_n is a value-result pa-
rameter; it should initially contain the amount of space pointed to by
_a_d_d_r; on return it will contain the actual length (in bytes) of the ad-
dress returned. This call is used with connection-based socket types,
currently with SOCK_STREAM.
It is possible to select(2) a socket for the purposes of doing an
aacccceepptt() by selecting it for read.
For certain protocols which require an explicit confirmation, such as ISO
or DATAKIT, aacccceepptt() can be thought of as merely dequeuing the next con-
nection request and not implying confirmation. Confirmation can be im-
plied by a normal read or write on the new file descriptor, and rejection
can be implied by closing the new socket.
One can obtain user connection request data without confirming the con-
nection by issuing a recvmsg(2) call with an _m_s_g___i_o_v_l_e_n of 0 and a non-
zero _m_s_g___c_o_n_t_r_o_l_l_e_n, or by issuing a getsockopt(2) request. Similarly,
one can provide user connection rejection information by issuing a
sendmsg(2) call with providing only the control information, or by call-
ing setsockopt(2).
RREETTUURRNN VVAALLUUEESS
The call returns -1 on error. If it succeeds, it returns a non-negative
integer that is a descriptor for the accepted socket.
EERRRROORRSS
The aacccceepptt() will fail if:
[EBADF] The descriptor is invalid.
[ENOTSOCK] The descriptor references a file, not a socket.
[EOPNOTSUPP] The referenced socket is not of type SOCK_STREAM.
[EFAULT] The _a_d_d_r parameter is not in a writable part of the user
address space.
[EWOULDBLOCK]
The socket is marked non-blocking and no connections are
present to be accepted.
SSEEEE AALLSSOO
bind(2), connect(2), listen(2), select(2), socket(2)
HHIISSTTOORRYY
The aacccceepptt() function appeared in 4.2BSD.
4.2 Berkeley Distribution December 11, 1993 2